<?php
header("content-type:text/html;charset=utf-8");

$code = $_POST["a"];
$name = $_POST["b"];
$sex = $_POST["c"];
$nation = $_POST["d"];
$e = $_POST['e'];


$hostname = "localhost";//数据库主机名，可以是IP
$database = "pro"; 		//数据库名称
$username = "root";		//数据库用户名
$password = "root";	//数据库密码
//连接数据库服务器
$connection = @mysql_connect($hostname,$username,$password) or exit(@mysql_error());
//设置字符集
@mysql_query("set names 'utf8'");
//选择数据库
@mysql_select_db($database,$connection) or exit(@mysql_error());
//执行sql语句

$sql = "INSERT INTO `product` values('{$e}','{$code}','{$name}',{$sex},'{$nation}')";

$result = @mysql_query($sql);
if($result == false){
	$error = "sql执行出错，错误编号：" . mysql_errno() . "错误原因：" . mysql_error();
	@mysql_close($connection);
	exit($error);
}

if($result)
{
//跳转页面
header("location:o.php");  //删除成功，则跳转回显示页面
}
else
{
echo "删除失败！";
}

@mysql_close($connection);

?>